//index.js
//获取应用实例
var sk = require('../../utils/i2f-securityKeyboard.js');
var util = require('../../utils/util.js');

var app = getApp();

Page({
  data: {
    securityKeyboard_input: ['',''],
    securityKeyboard_input_index: 0,
    userInfo: {},
    securityKeyboard_image_src:"",
    systemInfo:util.getSystemInfo(),
    securityKeyboard:sk.getSecurityKeyboard(
      "http://127.0.0.1:8080/securityKeyboardWeb/SecurityKeyboardServlet",
      "standard", 
      util.getSystemInfo().windowWidth,
      util.getSystemInfo().windowHeight),
    securityKeyboard_image_height:0,
    securityKeyboard_image_top:1000,
    
  },
  //事件处理函数
  bindViewTap: function() {
    wx.navigateTo({
      url: '../logs/logs'
    })
  },
  onLoad: function () {
    console.log('onLoad')
    var that = this
    //调用应用实例的方法获取全局数据
    app.getUserInfo(function(userInfo){
      //更新数据
      that.setData({
        userInfo:userInfo
      })
    })
  },
  showStandardSecurityKeyboardView : function(event){
    this.setData({
          securityKeyboard_input_index:0
        });
    sk.showStandardSecurityKeyboardView(event,this);
  },
  showStandardSecurityKeyboardView1 : function(event){
    this.setData({
          securityKeyboard_input_index:1
        });
    sk.showStandardSecurityKeyboardView(event,this);
  },
  securityKeyboard_Touchstart : function (event){
    
    sk.securityKeyboard_Touchstart(event,this);
  },
  login_button : function(){
    wx.request({
      url: "http://127.0.0.1:8080/securityKeyboardWeb/SecurityKeyboardServlet", //仅为示例，并非真实的接口地址
      data: {
        pwd0: sk.getPwd(this.data.securityKeyboard)[0],
        pwd1: sk.getPwd(this.data.securityKeyboard)[1]
      },
      header: {
          'content-type': 'application/x-www-form-url-encoded'
      },
      success: function(res) {
        wx.showModal({
              title: '提示',
              content: "您输入的密码为："+res.data,
              success: function(res) {
                if (res.confirm) {
                  console.log('用户点击确定')
                }
              }
            });
      }
    });
    
  }
})
